function sum(n) {
    var count = 0;//计数器从0开始计数
    for (let index = 1; index < n; index++) {
        count+=index;
    }
    return count;
    
}